(define (cons-stream x y)
    (cons x (delay y))
)

(define (stream-car s) (car s))
(define (stream-cdr s) (force (cdr s)))

(define (stream-ref s n)
    (if (= n 0)
        (stream-car s)
        (stream-ref (stream-cdr s) (- n 1))
    )
)


(define (stream-map proc . argstreams)
    (define (create-args list)
        (car list)
    )
    (define (next-list list)
        (cdr list)
    )
    (if  (null? (car argstreams ))
        `()
        (begin
            (apply proc 
                (map create-args argstreams)
            )
            (apply stream-map 
                (cons proc (map next-list argstreams))
            )
        )
    )
)


(define (intergers-starting-from n)
    (cons-stream n (intergers-starting-from (+ n 1)))
)

(define integers (intergers-starting-from 1))

(display (stream-ref integers 4))
(newline)

(define (add-streams s1 s2)
    (stream-map + s1 s2)
)
(display (stream-ref (add-streams integers integers) 4))
(exit)